package com.gxa.learning.pc.schedule;

import com.gxa.learning.core.pojo.FlowPathNode;
import com.gxa.learning.pc.service.FlowPathNodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

/**
 * 定时提醒
 *
 * @author YXQ
 * @date 2021/12/1 0:19
 */
@Component
public class ImageSchedule {

    @Autowired
    private FlowPathNodeService flowPathNodeService;

    /**
     * 每隔1秒执行一次
     */
    // @Scheduled(fixedRate = 1800000)
    // @Scheduled(fixedRate = 30000)
    public void executeScheduledTask() throws ParseException {
        List<FlowPathNode> flowPathNodes = flowPathNodeService.selectAll();
        for (FlowPathNode flowPathNode : flowPathNodes) {
            Date date = new Date();
            long time = flowPathNode.getExpirationDate().getTime() - date.getTime();
            long 时间 = time / (1000 * 60 * 60);
            System.out.println("时间： " + 时间);
            if (时间 < flowPathNode.getExpirationDateRemind()) {
                System.out.println("到点提醒!!!!!!!!!!");
            }

        }
    }
}
